function sortStr (str) {
  if (str.length <= 1) return 'NO'
  // console.log(str.split(''))
  // console.log(str.split('').join(''))
  let newArr = str.split('')
  let tmp = Math.floor(newArr.length / 2)
  // console.log(tmp)
  // let Arr = [...new Set(newArr)]
  // console.log(Arr)
  for (let i = 0; i < newArr.length; i++) {
    
    if (newArr.indexOf(newArr[i]) + newArr.lastIndexOf(newArr[i]) !== newArr.length - 1) {
      // console.log(newArr[0])
      // console.log(newArr.indexOf(newArr[i]))
      // console.log(newArr.lastIndexOf(newArr[i]))
      if (i == tmp) {
        return 'YES'
      }
    } else {
      if (newArr[i] == newArr[i + 1] || i == tmp) {
        return 'NO'
      } else {
        return 'YES'
      }
    }
  }
}

let str = 'aaaa'
console.log(sortStr(str))